#pragma once
#include<iostream>
using namespace std;
#include<pthread.h>


//自己来封装一个锁的接口

class Mutex{
public:
    Mutex(pthread_mutex_t* lock):_lock(lock){

    }

    void lock(){
        if(_lock) pthread_mutex_lock(_lock);
    }
    void unlock(){
        if(_lock) pthread_mutex_unlock(_lock);
    }


    ~Mutex(){

    }
public:
    pthread_mutex_t* _lock;
};




class lockguard{
public:
    lockguard(pthread_mutex_t* mutex):_mutex(mutex){
        _mutex.lock();
    }

    ~lockguard(){
        _mutex.unlock();
    }

public:
    Mutex _mutex;


};